package com.xbongbong.saas.enums;

import com.xbongbong.i18n.util.I18nMessageUtil;
import lombok.Getter;

import java.util.ArrayList;
import java.util.List;

/**
 * 操作类型枚举，用于日志记录
 * 来着 SAAS 项目
 * @author old version
 * @since old version
 */
@Getter
public enum OperateTypeEnum {
	/**
	 * 操作枚举，用于记录日志
	 */
	NEW(1,"enum.operateType.name.new","new"),


	EDIT(2,"enum.operateType.name.edit","edit"),


	DELETE(3,"enum.operateType.name.delete","delete"),

	/**
	 *  删除审批
	 */
	APPROVAL_DEL(70,"enum.operateType.name.approval_del","approvalDel"),


	IMPORT(4,"enum.operateType.name.import","import"),


	EXPORT(5,"enum.operateType.name.export","export"),


	DISTRIBUTE(6,"enum.operateType.name.distribute","distribute"),


	SET(7,"enum.operateType.name.set","set"),


	ENABLE(8,"enum.operateType.name.enable","enable"),


	CLOSE(9,"enum.operateType.name.close","close"),


	HANDOVER(10,"enum.operateType.name.handover","handover"),


	RETURN_TO_PUBLIC(11,"enum.operateType.name.return_to_public","returnToPublic"),


	SNATCH_CUSTOMER_FROM_PUBLIC(12,"enum.operateType.name.snatch_customer_from_public","snatchCustomerFromPublic"),


	REVERT(13,"enum.operateType.name.revert","revert"),


	AGREE(14,"enum.operateType.name.agree","agree"),


	REFUSE(15,"enum.operateType.name.refuse","refuse"),


	BACK(16,"enum.operateType.name.back","back"),


	STORAGE(17,"enum.operateType.name.storage","storage"),


	TRANSFER(18,"enum.operateType.name.transfer","transfer"),


	ARCHIVED(19,"enum.operateType.name.archived","archived"),


	CANCEL_ARCHIVED(20,"enum.operateType.name.cancel_archived","cancelArchived"),


	UPDATE_STOCK(21,"enum.operateType.name.update_stock","updateStock"),


	SET_VISIBLE_SCOPES(22,"enum.operateType.name.set_visible_scopes","setVisibleScopes"),


	ONLINE(23,"enum.operateType.name.online","online"),


	OFFLINE(24,"enum.operateType.name.offline","offline"),


	CANCEL(25,"enum.operateType.name.cancel","cancel"),


	REVERT_CANCEL(26,"enum.operateType.name.revert_cancel","revertCancel"),



	COVERAGE(27,"enum.operateType.name.coverage","coverage"),


	COPY(28,"enum.operateType.name.copy","copy"),


	NEW_VERSION(29,"enum.operateType.name.new_version","newVersion"),


    DOWNLOAD(30,"enum.operateType.name.download","downLoad"),

	/**
	 * 业务规则日志记录
	 */

	RULE_NEW(31, "enum.operateType.name.new.rule", "ruleNew"),

	RULE_DELETE(32, "enum.operateType.name.delete.rule", "ruleDelete"),


	RULE_EDIT(33, "enum.operateType.name.edit.rule", "ruleEdit"),

	UNABLE(38,"enum.operateType.name.unable","unable"),

	YES(39,"enum.operateType.name.yes","1"),

	NO(40,"enum.operateType.name.no","0"),

	/**
	 * 标签
	 */
	TO_RECYCLE_BIN(41,"enum.operateType.name.to_recycel_bin","recycleBin"),

	ADD_LABEL(42,"enum.operateType.name.add_label","addLabel"),

	REMOVE_LABEL(43,"enum.operateType.name.remove_label","removeLabel"),

	SNATCH_CLUE_FROM_PUBLIC(50,"enum.operateType.name.snatch_clue_from_public","snatchClueFromPublic"),

	RECOVER_LABEL(44,"enum.operateType.name.recover_label","recoverLabel"),

	FORM_LABEL_SETTINGS(45,"enum.operateType.name.form_label_settings","formLabelSettings"),

	EDIT_LABEL(46,"enum.operateType.name.edit_label","editLabel"),



	/**
	 * 客户合并
	 */
	CUSTOMER_MERGE(51,"enum.operateType.name.custmer_merge","customerMerge"),

	COMPLETELY_DELETE(52, "enum.operateType.name.completely_delete", "completelyDelete"),


	/**
	 * 线索转换客户
	 */
	TRANSFORM(53,"enum.operateType.name.transform","transform"),

	/**
	 * 删除（表单字段）
	 */
	ATTR_DELETE(54,"enum.operateType.name.attr_delete","attrDelete"),
	/**
	 * 恢复（表单字段）
	 */
	ATTR_RECOVER(55,"enum.operateType.name.attr_recover","attrRecover"),

	/**
	 * 数据校正
	 */
	DATA_FIX(56, "enum.operateType.name.data_fix", "dataFix"),

	/**
	 * 连接器历史数据初始化
	 */
	CONNECTOR_HISTORY_DATA_INIT(57, "enum.operateType.name.connector_history_data_init", "connectorHistoryDataInit"),
	/**
	 * 向连接器推数据
	 */
	PUSH_DATA_CONNECTOR(58, "enum.operateType.name.push_data_connector", "pushDataConnector"),
	/**
	 * 接收连接器推数据
	 */
	RECEIVE_DATA_CONNECTOR(59, "enum.operateType.name.receive_data_connector", "receiveDataConnector"),

	UNKNOWN(404,"enum.operateType.name.unknown","unknown"),

	/**
	 * 精线索联系方式解锁
	 */
	UNLOCKCONTACTINFO(60,"enum.operateType.name.unlockContactInfo","unlockContactInfo"),
	/**
	 * 线索转客户/线索
	 */
	CLUETRANSFERCUSTOMERORCLUE(61,"enum.operateType.name.clueTranserCustomerOrClue","clueTranserCustomerOrClue"),
	/**
	 * 开启坐席
	 */
	OPEONSTAFF(62,"enum.operateType.name.openStaff","openStaff"),
	/**
	 * 关闭坐席
	 */
    CLOSESTAFF(63,"enum.operateType.name.closeStaff","openStaff"),

	/**
	 * 关注
	 */
	FOCUS(64,"enum.operateType.name.focus","focus"),
	/**
	 * 取消
	 */
	ABOLISH(65,"enum.operateType.name.abolish","abolish"),
	/**
	 * 完成
	 */
	FINISH(66,"enum.operateType.name.finish","finish"),
	/**
	 * 批量变更公海分组
	 */
	BATCH_CHANGE_PUBLIC_GROUP(67,"enum.operateType.name.batch_change_public_group","batchChangePublicGroup"),
	/**
	 * 转移公海池
	 */
	TRANSFER_TO_PUBLIC(68,"enum.operateType.name.transfer_to_public","transferToPublic"),
	/**
	 * 新增（审批评论）
	 */
	CREATE_APPROVE_COMMENT(69,"enum.operateType.name.create_approve_comment","createApproveComment"),

	/**
	 * 编辑（审批评论）
	 */
	EDIT_APPROVE_COMMENT(71,"enum.operateType.name.edit_approve_comment","editApproveComment"),

	/**
	 * 删除（审批评论）
	 */
	DEL_APPROVE_COMMENT(72,"enum.operateType.name.del_approve_comment","delApproveComment"),
	/**
	 * 低代码发布
	 */
	LOW_CODE_RELEASE(73, "enum.operateType.name.low_code_release", "lowCodeRelease"),

	/**
	 * 设置可见范围
	 */
	SET_VISIBLE_RANGE(74,"enum.operateType.name.set_visible_range","setVisibleRange"),

	/**
	 * 合同对比
	 */
	CONTRACTCOMPARE(75,"enum.operateType.name.contractCompare","contractCompare"),



	/**
	 * 查看
	 */
	VIEW(76,"enum.operateType.name.view","view"),

	;


	/** 枚举值 -- 操作类型标识*/
	private final int	 code;

	/** 枚举信息--操作名称*/
	private final String name;

	/** 枚举描述 --角色使用时状态*/
	private final String alias;

	/**
	 * 构造一个<code>OperateTypeEnum</code>枚举对象
	 *
	 * @param code 操作码
	 * @param name 操作名称
	 * @param alias 操作别名
	 */
	OperateTypeEnum(int code, String name, String alias) {
		this.code = code;
		this.name = name;
		this.alias = alias;
	}

	/**
	 * 通过枚举<code>alias</code>获得枚举
	 *
	 * @param alias 操作别名
	 * @return OperateTypeEnum
	 */
	public static OperateTypeEnum getByAlias(String alias) {
		for (OperateTypeEnum cacheCode : values()) {
			if (cacheCode.getAlias().equals(alias)) {
				return cacheCode;
			}
		}
		return UNKNOWN;
	}

	/**
	 * 通过枚举<code>code</code>获得枚举
	 *
	 * @param code 操作码
	 * @return OperateTypeEnum
	 */
	public static OperateTypeEnum getByCode(Integer code) {
		for (OperateTypeEnum cacheCode : values()) {
			if (code.equals(cacheCode.getCode())) {
				return cacheCode;
			}
		}
		return UNKNOWN;
	}

	/**
	 * 获取全部枚举
	 *
	 * @return List<OperateTypeEnum>
	 */
	public static List<OperateTypeEnum> getAllEnum() {
		List<OperateTypeEnum> list = new ArrayList<>();
		for (OperateTypeEnum cache : values()) {
			if (cache == UNKNOWN) {
				continue;
			}
			list.add(cache);
		}
		return list;
	}

	/**
	 * 获取全部枚举值
	 *
	 * @return List<String>
	 */
	public static List<String> getAllEnumAlis() {
		List<String> list = new ArrayList<>();
		for (OperateTypeEnum cache : values()) {
			if (cache == UNKNOWN) {
				continue;
			}
			list.add(cache.getAlias());
		}
		return list;
	}

	public String getName() {
		return I18nMessageUtil.getMessage(name);
	}

	/**
	 * 获取开关标示枚举
	 * @return
	 */
	public static List<OperateTypeEnum> getSwitchByImport(){
		List<OperateTypeEnum> importSwitchs = new ArrayList<>();
		importSwitchs.add(YES);
		importSwitchs.add(NO);
		return importSwitchs;
	}

}
